package com.example.demo.event.listener;

import com.example.demo.event.base.AbstractAsyncEventListener;
import com.example.demo.event.base.EventSource;
import com.example.demo.event.source.Demo2EventSource;
import com.example.demo.event.source.DemoEventSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * demo2事件监听
 */
@Component
public class Demo2EventListener extends AbstractAsyncEventListener<Demo2EventSource> {

	private final static Logger LOG = LoggerFactory.getLogger(Demo2EventListener.class);


	@Override
	public void exec(EventSource<Demo2EventSource> eventSource) {
		Demo2EventSource eventVO = eventSource.getSource();

		if("ACTION_2".equals(eventSource.getAction())){
			System.out.println("action="+eventSource.getAction());

			LOG.info("接收事件： source={}", eventVO.toString());

			// do something......
			LOG.info("具体业务处理......");

			LOG.info("处理事件完毕： source={}", eventVO.toString());
		}

	}

}
